
local playertag = "abc"

--1.添加自己角色的命运星座
--使用方法：直接粘贴到模组环境 修改"abc"为玩家对应tag
    local usenum = 1 -- 每天的使用次数
    local function DoSkill(doer)
        -- 命运星座效果
    end
    local function mingyunxingzuo(inst, doer, pos)
        if doer and (doer.ray_shiejikeshiyongcishu == nil or doer.ray_shiejikeshiyongcishu < usenum) then

            DoSkill(doer)

            SendModRPCToClient(
                CLIENT_MOD_RPC["ray"]["kehuduanshuohuatongzhi"],
                doer.userid,
                " 技能名字：仅自己可见的技能介绍（每天一次）。",
                205,
                0,
                0
            )
        end
        return true
    end
AddPrefabPostInit("ray_zhouhuo", function(inst) 
    local SPELLS = inst.SPELLS
    local _onselect = SPELLS and SPELLS[1] and SPELLS[1].onselect
    if _onselect then   
        inst.SPELLS[1].onselect = function(inst, ...)
            _onselect(inst, ...)
            if TheWorld.ismastersim then
                local spellfn = inst.components.aoespell and inst.components.aoespell.spellfn
                if spellfn then
                    inst.components.aoespell:SetSpellFn(function(inst, doer, pos, ...)
                        return doer and doer:HasTag(playertag) and mingyunxingzuo(inst, doer, pos) or spellfn(inst, doer, pos, ...)
                    end)
                end
            end
        end
    end
end)


--2.免疫体力消耗
--使用方法：直接粘贴到模组环境 修改"c"为玩家prefab
local playerprefab = "c"
AddPrefabPostInit(playerprefab, function(inst) 
    if inst.components.ray_pilaozhi then
        -- 因为体力上限可能掉到0以下
        inst.components.ray_pilaozhi.max2 = math.max(inst.components.ray_pilaozhi.max2, 200)
        
        local _DoDelta = inst.components.ray_pilaozhi.DoDelta
        if _DoDelta then
            function inst.components.ray_pilaozhi:DoDelta(delta, overtime, ignore_invincible, ...)
                if delta then
                    delta = math.max(0, delta)
                end
                return _DoDelta(self, delta, overtime, ignore_invincible, ...)
            end
        end
        local _DoDelta2 = inst.components.ray_pilaozhi.DoDelta2
        if _DoDelta2 then
            function inst.components.ray_pilaozhi:DoDelta2(delta, overtime, ignore_invincible, ...)
                if delta then
                    delta = math.max(0, delta)
                end
                return _DoDelta2(self, delta, overtime, ignore_invincible, ...)
            end
        end
    end
end)
